<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" 	uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" 	%>

<jsp:useBean id="manager" 	class="chat.bean.ChatRoomManager" scope="request" /> 
<jsp:setProperty name="manager" 	property="*" />

<c:set var="chatRoom" value="${ manager.chatRoom }" />

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP 채팅 </title>
<style>
	body {
		border-top: 1px solid black;
		border-bottom: 1px solid black;
	}
</style>

<script>
	function checkSendMsg() {
		// 사용자 아이디와 전송 메시지 미 입력시 메시지를 팝업한다.
		var userName = document.getElementById( "userName" );
		if( userName.value == '' ) {
			alert( "채팅방 아이디를 입력하세요." );
			userName.focus();
			return false;
		}
		
		var msgText = document.getElementById( "msgText" );
		
		if( msgText.value == '' ) {
			alert( "메시지를 입력하세요." );
			msgText.focus();
			return false;
		}
		return true;
	}
</script>
	
</head>
<body>
	<h3><a href="../index.html">첫 페이지</a></h3>
	<h3>JSP 채팅 프로그램 </h3>
	<hr/>
	<p> 방제목: ${ chatRoom.chatRoomDispName } </p>
	<p> 개설자: ${ chatRoom.chatRoomUserName } </p>
	<p> 채팅 메시지 : </p>
	<iframe name="chatView" src="chatView.jsp#bottom" 
			width="500" height="300" scrolling="yes"
			frameborder="0" align="bottom"
			style="border:medium double black"
	>
	</iframe> 
	<br/>
	<hr/>
	<form target="chatView" method="get" action="chatView.jsp#bottom" onSubmit="return checkSendMsg();" > 
		<ul style="padding-left:20px;">
			<li>
				<label for="userName">아이디</label> 
				<input type="text" id="userName" name="userName" size="10" value="" />
			</li>
			<li>
				<label for="msgText">메시지</label>
				<input type="text" 	 id="msgText" name="msgText" size="40" value="" />
				<input type="hidden" name="chatRoomId" value = "${ param.chatRoomId }"/>  
				<input type="submit" value="전송" />
			</li>
		</ul> 
	</form>
</body>
</html>